package pdd;

import java.util.*;

/**
 * @author zhangmin
 * @create 2022-03-20 20:34
 */
public class PDD_0320_4 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int T=cin.nextInt();
        for (int t = 0; t < T; t++) {
            int n=cin.nextInt(),k=cin.nextInt();
            cin.nextLine();
            String s=cin.nextLine();
            if (k==1){
                System.out.println(s);
                continue;
            }
            if (n%k!=0){
                System.out.println(-1);
                continue;
            }
            Map<Character,Integer> set=new HashMap<>();
            for (int i = 0; i < s.length(); i++) {
                set.put(s.charAt(i),set.getOrDefault(s.charAt(i),0)+1);
            }
            for (char i = 'a'; i <= 'z'; i++) {
                if (set.containsKey(i)&&set.get(i)%k!=0){
                    break;
                }
            }
            System.out.println();
        }
    }
}
